#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/4/15 15:03
# @Author  : Chenmm
# @File    : menu.py
# @Software: PyCharm


from app.api import api
from flask import Flask, request, g, jsonify, send_file, session, current_app
from flask_login import login_required, login_user, current_user, logout_user



def setAccessable(resource, permitedIDList):
    if resource.ID not in permitedIDList:
        resource.HIDDEN = True

    for child in resource.children:
        setAccessable(child, permitedIDList)



# 获取当前用户的路由列表
@api.route('/menus/routes')
@login_required
def getRoutes():
    menus = []
    menus += [menu for role in current_user.roles for menu in role.menus if role.menus]
    data = [menu.to_router_json() for menu in menus if menu.parent_id == 0]

    return jsonify(
        {'code': '00000', 'data': data,
         'msg': '一切ok'})

